package com.superview.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class PinyinRuntime {
	private String pyPath = "C:\\\\ProgramData\\\\Anaconda3\\\\python.exe";
	private String funcPath = "D:\\\\\\\\develop\\\\\\\\python-pinyin-master\\\\\\\\python-pinyin-master\\\\\\\\test_run.py";
	
	public String GetPinyin(String chinese) {
		try {
			String[] ars = new String[] { getPyPath(), getFuncPath(),chinese};
			Process pr;
	        pr = Runtime.getRuntime().exec(ars);
	      //用输入输出流来截取结果
            BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream(),Charset.forName("GBK")));
            String line = null;
            line = in.readLine();
            in.close();
	        pr.waitFor();
	        return line;
		} catch (Throwable t) {
			t.printStackTrace();
		}
		return null;
	}

	public String getPyPath() {
		return pyPath;
	}

	public String getFuncPath() {
		return funcPath;
	}
	
}
